fix(_function_parameter_parse_util): return [] not None for empty schema properties#5921
Conversation
…pty schema properties _get_required_fields() had a bare `return` that returned None when schema.properties was falsy. The None was assigned to declaration.parameters.required, causing TypeError: 'NoneType' object is not iterable in any downstream code that iterated over .required. Fixes google#5920
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Response from ADK Triaging Agent Hello @devteamaegis, thank you for creating this PR! We noticed that this PR is not fully following the contribution guidelines yet:
Once the CLA is signed and the status check passes, our team will be able to review your PR. Thank you! |
|
Hi @devteamaegis , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you! |
What's broken
_get_required_fields()insrc/google/adk/tools/_function_parameter_parse_util.pyreturnsNone(barereturnstatement, line 437) whenschema.propertiesis falsy. The caller in_automatic_function_calling_util.pyassigns the result directly todeclaration.parameters.required. Any code that then iterates over.requiredraisesTypeError: 'NoneType' object is not iterable. This fires for any function whose properties dict is empty — for example, a function that only takestool_contextonce it's been added toignore_params.Why it happens
returnwith no value in alist[str]-annotated function returnsNoneinstead of the expected empty list.Fix
Line 437: changed
returntoreturn []. One character change.Test
Added
test_empty_properties_required_is_empty_list_not_noneinTestBuildFunctionDeclarationLegacy. It calls_get_required_fieldswith an empty-properties schema and asserts the result is[]and is iterable without raising.Fixes #5920